#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<string>
using namespace std;
int myAtoi(string str) {
    int i = 0;
    int bigsize = INT_MAX / 10;
    if (str.size() == 0)
        return 0;
    while (str[i++] == ' ')
    {
        if (i == str.size())
            return 0;
    }
    int sign = 1;
    if (str[i++] == '-')
    {
        sign = -1;

    }

    int ret = 0;
    for (int j = i; j < str.size(); j++)
    {
        if (str[j] < '0' || str[j]>'9')
            break;
        if (ret > bigsize || (ret == bigsize && str[j] < '7'))
            return sign == 1 ? INT_MAX : INT_MIN;
        ret = ret * 10 + (str[j] - '0');


    }
    return ret * sign;
}
int main()
{


    string s1 = "42";
    myAtoi(s1);
    return 0;
}